home *** CD-ROM | disk | FTP | other *** search
- /******************************************************************************
- Example of Using COM Ports with standard C funtions.
-
- by: Karl Weller
- [74620,2112]
- ******************************************************************************/
- #include "stdio.h"
- #include "time.h"
-
- main()
- {
- FILE *fp;
- int i;
- char comport[10];
- long t1,t2;
-
- printf("\Which COM PORT (1-4) ");
- i=getch();
-
- if (i<'0' || i>'4') exit(0);
- sprintf(comport,"COM%c",i);
-
- fp = fopen(comport,"w");
-
- printf("\nAnswering %s\n",comport);
- fprintf(fp,"ATA\n");
- fflush(fp);
-
- printf("WAIT 6 SECONDS\n");
- time(&t1);
- do {
- time(&t2);
- } while(t1+6L>t2);
-
- printf("HANGUP %s\n",comport);
- fprintf(fp,"ATH\n");
- fflush(fp);
-
- fclose(fp);
- }